package app.repositories.impl;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import app.models.Consulta;
import app.models.Relatorio;
import app.repositories.RelatorioRepository;
import app.repositories.Repository;
import br.com.caelum.vraptor.ioc.Component;

@Component
public class RelatorioRepositoryImpl
	extends Repository<Relatorio, Long>
	implements RelatorioRepository {

	protected RelatorioRepositoryImpl(EntityManager entityManager) {
		super(entityManager);
	}
	
	
	@SuppressWarnings("unchecked")
	@Override
	public List<Consulta> findConsultasUnpaidUntilTodayByFilter(String filter) {
		StringBuilder stringBuilder = new StringBuilder();
		
		stringBuilder.append("select * from consulta c where ");
		stringBuilder.append("c.");
		stringBuilder.append("or c.");
		stringBuilder.append("or c.");
		stringBuilder.append("c.tipo = 'PENDENTE' ");
		
		Query query = entityManager.createQuery(stringBuilder.toString());
		
		return query.getResultList();
	}

}
